<?php

function fnInsertUserSeminar($SeminarId,$UserId,$UserGroup) {
    $results = mysql_query("INSERT INTO `lst_seminar_user` (seminar_id,user_id,user_group)
                            VALUES ('$SeminarId','$UserId','$UserGroup')" );
    return $results;
}
    
function fnUpdateUserSeminar($SeminarId,$UserId,$UserGroup) {
    $results = mysql_query("UPDATE `lst_seminar_user` 
                            SET `user_group` = '$UserGroup'
                            WHERE `user_id` = '$UserId' 
                            AND `seminar_id` = '$SeminarId'");
    return $results;
}
    
function fnDeleteUserSeminar($SeminarId,$UserId,$UserGroup) {
    $results = mysql_query("DELETE FROM `lst_seminar_user` 
                            WHERE `seminar_id` = '$SeminarId' 
                            AND `user_group` = '$UserGroup' 
                            AND `user_id` = '$UserId'");
    return $results;
}

function fnSelectUserSeminar($TopikId,$UserId) {
    $results = mysql_query("SELECT * FROM lst_seminar_user 
                            WHERE seminar_id='".$TopikId."' 
                            AND user_id='".$UserId."'");
    return $results;
}

function fnUserAllSeminar($UserId) {
    $results = mysql_query("SELECT distinct a.* , b.user_id, b.user_group, b.keterangan, b.nama, b.kota, b.negara, b.telp, b.email  
                            FROM mst_seminar a LEFT OUTER JOIN v_list_mst_seminar_user_group b
                            ON a.seminar_id = b.seminar_id AND b.user_id = '$UserId' 
                            ORDER BY a.seminar_id");
    return $results;
}

function fnSelectAllUserGroup() {
    $results = mysql_query("SELECT * FROM `mst_group`");
    return $results;
}

function fnUserOnSeminar($UserId, $SeminarId) {
    $results = mysql_query("SELECT a.* , b.user_id, b.user_group, b.keterangan, b.nama, b.kota, b.negara, b.telp, b.email  
                            FROM mst_seminar a, v_list_mst_seminar_user_group b
                            WHERE a.seminar_id = b.seminar_id 
                            AND b.user_id = '$UserId' 
                            AND a.seminar_id = '$SeminarId' 
                            ORDER BY a.seminar_id");
    return $results;
}

?>
